package com.java.jetpackdemo.navigation.navigation_one

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.Navigation
import androidx.navigation.ui.NavigationUI
import com.java.jetpackdemo.R

class NavigationActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_navigation)

        //使顶部有返回的箭头
        val navController = Navigation.findNavController(this, R.id.fragment_natigation)
        NavigationUI.setupActionBarWithNavController(this, navController)
    }

    //使顶部箭头可以添加返回事件
    override fun onSupportNavigateUp(): Boolean {
        val navController = Navigation.findNavController(this, R.id.fragment_natigation)
        return navController.navigateUp()

    }
}
